var app = getApp()
var fun = require('../fun.js');

Page({

  data: {
    nav_top:app.globalData.nav_top,nav_title:'消息处理',show_cart:app.globalData.show_cart,bg:'https://zjhn-1253789145.cos.ap-guangzhou.myqcloud.com/bbg.jpg'
  },


  onLoad: function (op) {
var user_id=app.globalData.user_id;
if(!user_id || user_id==0){this.setData({login_show:'show'});}
var that=this;

  },
  login: function (e) {
    var c = e.currentTarget.dataset.c;
    if(c=='close'){this.setData({login_show:'hide'});return;}
    fun.go_login().then(res => {
      if (res == 'ok') {
        app.msg('登录成功');
        this.load();
        this.setData({ login_show: 'hide' });
      }
    });

  },

  onReady: function () {
   
  },


  onShow: function () {
    this.load();
  },


  load: function () {
var that=this;
wx.request({
  url: app.globalData.server,
  data:{
ac:'get_adm_msg',user_id:app.globalData.user_id,session:app.globalData.session

  },success(res){
if(!res.data){return;}console.log(res.data);
if(res.data.err!='ok'){
if(res.data.err=='no_login'){that.setData({login_show:'show'});return}
app.err(res.data.err);return;
}

that.setData({list:res.data.list,user:res.data.user})

  }
})


  },
  go:function(e){
  var url=e.currentTarget.dataset.url;
  wx.navigateTo({
    url: url,
  })
  },
back:function(){
wx.navigateBack({
  delta: 0,
})

},

  
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})